<?php

use Biz\model\brand\Content as mBrandContent;

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';
ini_set('memory_limit', '512M');


echo (ini_get('memory_limit')) , PHP_EOL;
$ids = $argv[1] ?? '';
$brand_id = $argv[2] ?? '';
$debug = $argv[3] ?? false;
$exec = $argv[4] ?? false;

if ($brand_id) {

    if ($debug) \Biz\service\wiki\WikiContentSync::debug();

    if ($exec) \Biz\service\wiki\WikiContentSync::exec();

    if (is_string($ids)) $ids = explode(',', $ids);

    $ids = array_filter($ids);
    $ids = array_values((array)$ids);

    $ids = empty($ids) ? mBrandContent::select('obj_id', ['brand_id' => $brand_id]) : $ids;
    $ids = array_flip(array_flip($ids));
    var_dump(count($ids), $brand_id);
    \Biz\service\wiki\WikiContentSync::consumeContent($ids, $brand_id);
}




